package hr.dario.fragments.app;

import hr.dario.fragments.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class NaslovActivity extends Activity {

	private static final int ACTIVITY_CREATE = 0;

	private Activity activity = this;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		Button btn = (Button) this
				.findViewById(R.id.naslovna_btn_zujanje_okolo);
		btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(activity, ActionBarTabsPager.class);
				startActivity(i);
			}
		});

		btn = (Button) this.findViewById(R.id.naslovna_btn_moja_koshnica);
		btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(activity, ActionBarTabsPager.class);
				startActivity(i);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.option_menu_main, menu);
		return true;
	}

	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		switch (item.getItemId()) {
		case R.id.item1:
			createLocation();
			return true;
		case R.id.item2:
			createEvent();
			return true;
		}

		return super.onMenuItemSelected(featureId, item);
	}

	private void createLocation() {
		Intent i = new Intent(this, LocationEdit.class);
		startActivityForResult(i, ACTIVITY_CREATE);
	}

	private void createEvent() {
		Intent i = new Intent(this, EventEdit.class);
		startActivityForResult(i, ACTIVITY_CREATE);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
		super.onActivityResult(requestCode, resultCode, intent);

	}
}